package com.blueberry.commbank.domain.entity;

import java.math.BigDecimal;
import java.util.Currency;

public class Money implements Comparable<Money> {
    private BigDecimal amount;
    private Currency currency;

    public Money(BigDecimal amount, Currency currency) {
        this.amount = amount;
        this.currency = currency;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public Currency getCurrency() {
        return currency;
    }

    public void setCurrency(Currency currency) {
        this.currency = currency;
    }

    public Money add(Money money) {
        return new Money(amount.add(money.getAmount()), this.currency);
    }

    public Money subtract(Money money) {
        return new Money(amount.subtract(money.getAmount()), this.currency);
    }

    @Override
    public int compareTo(Money o) {
        return Integer.compare(this.amount.compareTo(o.amount), 0);
    }
}
